﻿//初始化入口
$(function() {
    fn_Tree();
    $('#dlgresult-addData').dialog('close');
    $('#dlgresult-searchDataSource').dialog('close');
});

function fn_Tree() {
    $('#treeload').tree({
        url: "Controller.aspx?controller=ReportController&method=GetGroupRights",
        onClick: function(node) {
            $(this).tree('toggle', node.target);
            if (parseInt(node.attributes.type) == 1) {
                $('#btn_searchReport').linkbutton('enable');
                //printDivPreview($('#printDiv'));
            } else {
                $('#btn_searchReport').linkbutton('disable');
                $('#printDiv').empty();
            }
        }
    });
}

//报表查询
function onStartSearchData() {
    var selected = $('#treeload').tree('getSelected');
    if (selected) {
        requestAjax('Controller.aspx?controller=ReportController&method=LoadPageReportSearch&titleId=' + selected.id, {}, function(data) {
            $('#addDataDiv').empty();
            $('#addDataDiv').load("ReportSearchdlg.aspx", {}, function() {
                $.parser.parse($('#addDataDiv'));
            });
        });
        $('#dlgresult-addData').dialog('open');
    }
}

//报表查询确定
function dlgsearch_reportOk() {
    var selected = $('#treeload').tree('getSelected');
    if (selected) {
        FormSubmit($('#formreportsearch'), 'Controller.aspx?controller=ReportController&method=ExecProcedure&titleId=' + selected.id, function() {
            $('#dlgresult-addData').dialog('close');
            printDivPreview($('#printDiv'));
        });
    }
}